<script>
export default {
  methods:{
    getSessionId(){
      this.$ajax
        .post(this.$api.getSessionId)
        .then(res => {
          // this.$store.dispatch("changeSessionId", res);
          uni.setStorageSync('sessionId', res);
        })
        .catch(err => {
          uni.showToast({
            title: err,
            icon: 'warn',
            duration: 2000
          })
        });
    },
    checkToken(){
      this.$ajax
        .post(this.$api.checkToken)
        .then(res => {
          if(res){
            this.$store.dispatch("changeLoginStatus", true);
          } else {
            uni.removeStorageSync('token')
            this.$store.dispatch("changeLoginStatus", false);
          }
        })
        .catch(err => {
          uni.showToast({
            title: err,
            icon: 'warn',
            duration: 2000
          })
        });
    }
  },
  created () {
    let token = uni.getStorageSync('token');
    this.getSessionId();
    if(token){
      this.checkToken()
    }
  }
}
</script>

<style>
	@keyframes show {
			0% {
				transform: translateY(-10px);
			}
	
			60% {
				transform: translateY(20upx);
			}
	
			100% {
				transform: translateY(0px);
			}
		}
	
		@-webkit-keyframes show {
			0% {
				transform: translateY(-10px);
			}
	
			60% {
				transform: translateY(20upx);
			}
	
			100% {
				transform: translateY(0px);
			}
		}
.container {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 200rpx 0;
  box-sizing: border-box;
}
/* this rule will be remove */
* {
  transition: width 2s;
  -moz-transition: width 2s;
  -webkit-transition: width 2s;
  -o-transition: width 2s;
}
</style>
